package cz.proks.easyhelpdesk.gwt.event;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

import cz.proks.easyhelpdesk.api.model.Helpdesk;

public class HelpdeskSaveEvent extends GwtEvent<HelpdeskSaveEvent.Handler> {
    public final static Type<HelpdeskSaveEvent.Handler> TYPE = new Type<HelpdeskSaveEvent.Handler>();
    
    public static interface Handler extends EventHandler {
        void onHelpdeskSave(HelpdeskSaveEvent event);
    }
    
    private final Helpdesk helpdesk;

    public HelpdeskSaveEvent(Helpdesk helpdesk) {    
        this.helpdesk = helpdesk;
    }
    
    public Helpdesk getHelpdesk() {
        return helpdesk;
    }
    
    public static void fireEvent(HasHelpdeskSaveHandlers source, Helpdesk helpdesk) {
        source.fireEvent(new HelpdeskSaveEvent(helpdesk));
    }

    @Override
    public com.google.gwt.event.shared.GwtEvent.Type<Handler> getAssociatedType() {
        return TYPE;
    }

    @Override
    protected void dispatch(Handler handler) {
        handler.onHelpdeskSave(this);
    }    
}
